package com.flynn.rock.system.entity;

import com.flynn.rock.enums.system.UserAccountStatus;
import com.flynn.rock.enums.system.UserAccountType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.LocalDateTime;

@Getter
@Setter
@Entity
@Table(name = "sys_user_account")
@EntityListeners(AuditingEntityListener.class)
public class SysUserAccountEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "user_account_id", nullable = false)
    private Long id;

    @Column(name = "account", length = 64)
    private String account;

    @Column(name = "password")
    private String password;

    @Column(name = "account_type", length = 32)
    @Enumerated(value = EnumType.STRING)
    private UserAccountType accountType;

    @Column(name = "login_ip", length = 64)
    private String loginIp;

    @Column(name = "first_login_time")
    private LocalDateTime firstLoginTime;

    @Column(name = "last_login_time")
    private LocalDateTime lastLoginTime;

    @CreatedDate
    @Column(name = "create_time")
    private LocalDateTime createTime;

    @LastModifiedDate
    @Column(name = "update_time")
    private LocalDateTime updateTime;

    @Column(name = "status", length = 32)
    @Enumerated(value = EnumType.STRING)
    private UserAccountStatus status;

    @Column(name = "user_id")
    private Long userId;
}